<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <th:block th:include="common.html :: source"></th:block>
    <link href="/static/layui/css/layui.css" rel="stylesheet">
</head>
<style>
    .layui-form-label{
        width: 100px;
    }
    .layui-input-block{
        margin-left: 100px;
    }
</style>
<body>
<div class="layui-input-block layui-form" id="modifyClass"
     lay-filter="updateClass" style="margin-top: 30px">
    <form class="layui-form" action="" lay-filter="example">

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">颜色</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="specsNameColor" id="specsNameColor" lay-verify="required"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">尺码</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="specsNameSize" id="specsNameSize" lay-verify="required"/>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">商品编号</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="shoeId" id="shoeId" lay-verify="required"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">库存</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="specsStock" id="specsStock" lay-verify="required"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">规格价格</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="specsPrice" id="specsPrice" lay-verify="required"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">商家类型</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="categoryType" id="categoryType" lay-verify="required"/>
                </div>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="enmodify">确认添加</button>
            </div>
        </div>
    </form>
</div>
<script src="/layui/layui.js" charset="UTF-8"></script>
<script type="text/javascript">
    layui.use(['layer', 'form'], function () {
        var layer = layui.layer;
        var form = layui.form;
        form.on('submit()', function () {
            $.post({
                url: '/manage/saveSpecsInfo',
                data: {
                    "specsId": $("#specsId").val(),
                    "specsIdColor": $("#specsIdColor").val(),
                    "specsIdSize": $("#specsIdSize").val(),
                    "specsNameSize": $("#specsNameSize").val(),
                    "specsNameColor": $("#specsNameColor").val(),
                    "specsStock": $("#specsStock").val(),
                    "specsPrice": $("#specsPrice").val(),
                    "shoeId": $("#shoeId").val(),
                    "categoryType": $("#categoryType").val(),
                },
                success: function (data) {
                    if (data === "true") {
                        layer.msg('添加成功！', {icon: 6, offset: "auto", time: 2000});//提示框
                    } else {
                        layer.msg('添加失败！', {icon: 5, offset: "auto", time: 2000});//提示框
                    }
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);//关闭弹出层
                        parent.location.reload();//重新加载父页面表格
                    }, 2100);
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
